package thread;

/**
 * 线程提供了一组获取自身相关信息的方法
 *
 * @author Luka
 * @date 2021/06/03 16:15
 **/
public class ThreadInfoDemo {
    public static void main(String[] args) {
        Thread main = Thread.currentThread();

        //获取线程的名字
        String name = main.getName();
        System.out.println(name);

        //获取线程的唯一标识
        long id = main.getId();
        System.out.println(id);

        //获取线程的优先级,默认值5,取值在1-10之间的整数
        int priority = main.getPriority();
        System.out.println(priority);
        //线程是否活着
        boolean isAlive = main.isAlive();
        //线程是否为守护线程
        boolean isDaemon = main.isDaemon();
        //线程是否被中断了
        boolean isInterrupted = main.isInterrupted();
        System.out.println("isAlive"+isAlive);
        System.out.println("isDaemon"+isDaemon);
        System.out.println("isInterrupted"+isInterrupted);
    }
}